home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / LIB / PRED_AND.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  3.3 KB  |  101 lines

  1.  
  2. package sub_arctic.lib;
  3.  
  4. /** 
  5.  * Interactor predicate class that does an AND operation across the results of
  6.  * two other interactor_pred objects it is composed out of.  The composed 
  7.  * objects both get the same test object and parameters and so must be 
  8.  * compatible in terms of the object types they expect.
  9.  *
  10.  * @see sub_arctic.lib.base_interactor#traverse_and_collect
  11.  * @author Scott Hudson
  12.  */
  13. public class pred_and implements interactor_pred {
  14.  
  15.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  16.  
  17.   /** First component predicate. */
  18.   protected interactor_pred _op1 = null;
  19.  
  20.   /** 
  21.    * First component predicate. 
  22.    * @return interactor_pred the first component predicate.
  23.    */
  24.   public interactor_pred op1() {return _op1;}
  25.  
  26.   /** 
  27.    * Set first component predicate.
  28.    * @param interactor_pred p the new first component predicate.
  29.    */
  30.   public void set_op1(interactor_pred p) {_op1 = p;}
  31.  
  32.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  33.  
  34.   /** Second component predicate */
  35.   protected interactor_pred _op2 = null;
  36.  
  37.   /** 
  38.    * Second component predicate.
  39.    * @return interactor_pred the second component predicate.
  40.    */
  41.   public interactor_pred op2() {return _op2;}
  42.  
  43.   /** 
  44.    * Set second component predicate.
  45.    * @param interactor_pred p the new first component predicate.
  46.    */
  47.   public void set_op2(interactor_pred p) {_op2 = p;}
  48.  
  49.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  50.  
  51.   /** 
  52.    * Construct new predicate from two other predicates.
  53.    * @param interactor_pred p1 the first predicate.
  54.    * @param interactor_pred p2 the second predicate.
  55.    */
  56.   public pred_and(interactor_pred p1, interactor_pred p2)
  57.     {
  58.       set_op1(p1);
  59.       set_op2(p2);
  60.     }
  61.  
  62.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  63.  
  64.   /** Perform the predicate test by ANDing the result of two component 
  65.    *  predicates.  Note: AND is done with && so the second predicate will not
  66.    *  be invoked if the first one returns false.
  67.    *  
  68.    *  @param obj        the interactor the predicate is testing.
  69.    *  @param parameters the additional parameters (of subclass specific type)
  70.    *                    to the predicate (passed to both component predicates).
  71.    *  @return AND of results from two component predicates.
  72.    */
  73.   public boolean test(interactor obj, Object parameters) 
  74.     {
  75.       return op1().test(obj, parameters) && op2().test(obj, parameters);
  76.     }
  77.  
  78.    //had:
  79.    //*  @exception sub_arctic.exception.bad_value thrown if the parameters 
  80.    //*     parameter is not the proper type for one or the other component 
  81.    //*     predicates.
  82.  
  83.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  84. }
  85. /*=========================== COPYRIGHT NOTICE ===========================
  86.  
  87. This file is part of the subArctic user interface toolkit.
  88.  
  89. Copyright (c) 1996 Scott Hudson and Ian Smith
  90. All rights reserved.
  91.  
  92. The subArctic system is freely available for most uses under the terms
  93. and conditions described in 
  94.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  95. and appearing in full in the lib/interactor.java source file.
  96.  
  97. The current release and additional information about this software can be 
  98. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  99.  
  100. ========================================================================*/
  101.